package com.socialuni.sdk.service.talk;

import com.socialuni.sdk.api.model.QO.talk.SocialUserTalkQueryQO;
import com.socialuni.sdk.api.model.RO.talk.SocialTalkRO;
import com.socialuni.sdk.api.model.ResultRO;
import com.socialuni.sdk.api.TalkAPI;
import com.socialuni.sdk.model.DO.user.AccountDO;
import com.socialuni.sdk.utils.model.SocialUserAccountUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author qinkaiyuan
 * @date 2020-05-16 20:11
 */
@Service
@Slf4j
public class SocialQueryUserTalksService {
    @Resource
    TalkAPI talkAPI;

    public ResultRO<List<SocialTalkRO>> queryUserTalks(SocialUserTalkQueryQO queryVO) {
        AccountDO accountDO = SocialUserAccountUtil.getUserSocialAccount(Integer.valueOf(queryVO.getUserId()));
        String centerUserId = accountDO.getUnionId();

        SocialUserTalkQueryQO socialUserTalkQueryQO = new SocialUserTalkQueryQO(centerUserId, queryVO.getTalkIds());

        return talkAPI.queryUserTalks(socialUserTalkQueryQO);
    }
}
